package com.lxr.test5002;

import android.bluetooth.BluetoothAdapter;
import android.content.Intent;
import android.hardware.Camera;
import android.os.Bundle;
import android.view.View;
import android.view.WindowManager;
import android.widget.GridView;
import com.lxr.test5002.adapter.FactoryTestIemAdapter;
import com.lxr.test5002.base.BaseActivity;
import com.lxr.test5002.base.Constants;
import com.lxr.test5002.bean.FactoryTestItem;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import butterknife.BindView;

/**
 * 类描述:[首页]
 * 说明:
 * @author: LXR-zsm
 * @Date: 2023/12/18 16:55
 */
public class MainActivity extends BaseActivity {
    @BindView(R.id.gv_test_items)
    GridView mGvTestItems;
    private List<FactoryTestItem> testItems;
    private FactoryTestIemAdapter mAdapter;

    public MainActivity() {
        super(R.layout.activity_main);
    }

    @Override
    protected void initView(Bundle savedInstanceState) {
        BluetoothAdapter adapter = BluetoothAdapter.getDefaultAdapter();
    }

    @Override
    public void initData() {
        testItems = new ArrayList<>();
        List<Map<String,Object>> mapList = Constants.getModel();
        for (int i = 0; i < mapList.size(); i++) {
            FactoryTestItem item = new FactoryTestItem(mapList.get(i).get("title").toString(),
                    true, (Integer) mapList.get(i).get("icon"), i);
            testItems.add(item);
        }
        mAdapter = new FactoryTestIemAdapter(this, testItems);
        mGvTestItems.setAdapter(mAdapter);
        mGvTestItems.setVisibility(View.VISIBLE);
    }

    @Override
    public void initEvent() {
        mAdapter.setOnGridButtonClickListener(position -> {
            Intent intent = null;
            switch (testItems.get(position).getTestId()) {
                case Constants.TEST_ITEM_INFO:
                    intent = new Intent(MainActivity.this, SettingActivity.class);
                    break;
                case Constants.TEST_ITEM_LCD:
                    intent = new Intent(MainActivity.this, LCDActivity.class);
                    break;
                case Constants.TEST_ITEM_TP:
                    intent = new Intent(MainActivity.this, TPActivity.class);
                    break;
//                case Constants.TEST_ITEM_KEY:
//                    intent = new Intent(MainActivity.this, KeyActivity.class);
//                    break;
                case Constants.TEST_ITEM_GPRS:
                    intent = new Intent(MainActivity.this, GprsActivity.class);
                    break;
                case Constants.TEST_ITEM_IC:
                    intent = new Intent(MainActivity.this, ICCActivity.class);
                    break;
//                case Constants.TEST_ITEM_SCAN:
//                    intent = new Intent(MainActivity.this, ScanActivity.class);
//                    break;
                case Constants.TEST_ITEM_AUDIO:
                    intent = new Intent(MainActivity.this, AudioActivity.class);
                    break;
                case Constants.TEST_ITEM_TF:
                    intent = new Intent(MainActivity.this, TFActivity.class);
                    break;
                case Constants.TEST_ITEM_USB:
                    intent = new Intent(MainActivity.this, USBActivity.class);
                    break;
//                case Constants.TEST_ITEM_FLASH:
//                    intent = new Intent(MainActivity.this, FlashActivity.class);
//                    break;
                case Constants.TEST_ITEM_CAMERA:
                    intent = new Intent(MainActivity.this, PhotoReviewAcitivty.class);
                    intent.putExtra("cameraId", Camera.CameraInfo.CAMERA_FACING_BACK);
                    break;
                case Constants.TEST_FONT_CAMERA:
                    intent = new Intent(MainActivity.this, PhotoReviewAcitivty.class);
                    intent.putExtra("cameraId", Camera.CameraInfo.CAMERA_FACING_FRONT);
                    break;
                case Constants.TEST_ITEM_BLUETOOTH:
                    intent = new Intent(MainActivity.this, BluTest.class);
                    break;
//                case Constants.TEST_ITEM_GPS:
//                    intent = new Intent(MainActivity.this, GPSActivity.class);
//                    break;
                case Constants.TEST_ITEM_WIFI:
                    intent = new Intent(MainActivity.this, WifiActivity.class);
                    break;
//                case Constants.TEST_ITEM_LIGHT_SENSOR:
//                    intent = new Intent(MainActivity.this, LightSensorActivity.class);
//                    break;
//                case Constants.TEST_ITEM_POINT:
//                    intent = new Intent(MainActivity.this, TestPcieActivity.class);
//                    break;
//                case Constants.TEST_ITEM_ZD:
//                    intent = new Intent(MainActivity.this, ZDActivity.class);
//                    break;
            }
            startActivity(intent);
        });
    }
    @Override
    protected void onDestroy() {
        super.onDestroy();
        getWindow().clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
    }
}
